import request from '@/utils/request';

/**
 * 分页查询用户
 */
export async function get_list(params) {
  const res = await request.post('/member/receipts_points_deduct/get_list', {
    ...params
  });
  if (res.data.code === 1) {
    return {
      list: res.data.data.row_list,
      columns: res.data.data.columns,
      searchData: res.data.data.search_area,
      count: res.data.data.page_info?.total,
      top_button: res.data.data.top_button
    };
  }
  return Promise.reject(res.data.msg);
}

/* 新建 */
export async function add(params) {
  const res = await request.post('/member/receipts_points_deduct/add', params);
  if (res.data.code === 1) {
    return res.data;
  }
  return Promise.reject(res.data.msg);
}
/* 编辑 */
export async function edit(params) {
  const res = await request.post('/member/receipts_points_deduct/edit', params);
  if (res.data.code === 1) {
    return res.data;
  }
  return Promise.reject(res.data.msg);
}
/* 详情 */
export async function get_detail(params) {
  const res = await request.post(
    '/member/receipts_points_deduct/member_detail',
    params
  );
  if (res.data.code === 1) {
    return res.data.data;
  }
  return Promise.reject(res.data.msg);
}
/* 作废 */
export async function cancel_receipts(params) {
  const res = await request.post(
    '/member/receipts_points_deduct/cancel_receipts',
    params
  );
  if (res.data.code === 1) {
    return res.data;
  }
  return Promise.reject(res.data.msg);
}
/* 删除 */
export async function del_receipts(params) {
  const res = await request.post(
    '/member/receipts_points_deduct/del_receipts',
    params
  );
  if (res.data.code === 1) {
    return res.data;
  }
  return Promise.reject(res.data.msg);
}
/* 提交审核 */
export async function confirm_receipts(params) {
  const res = await request.post(
    '/member/receipts_points_deduct/confirm_receipts',
    params
  );
  if (res.data.code === 1) {
    return res.data;
  }
  return Promise.reject(res.data.msg);
}
/* 取消审核 */
export async function cancel_verify(params) {
  const res = await request.post(
    '/member/receipts_points_deduct/cancel_verify',
    params
  );
  if (res.data.code === 1) {
    return res.data;
  }
  return Promise.reject(res.data.msg);
}
/* 审核 */
export async function verify_receipts(params) {
  const res = await request.post(
    '/member/receipts_points_deduct/verify_receipts',
    params
  );
  if (res.data.code === 1) {
    return res.data;
  }
  return Promise.reject(res.data.msg);
}

/* 删除客户 */
export async function del_member(params) {
  const res = await request.post(
    '/member/receipts_points_deduct/del_member',
    params
  );
  if (res.data.code === 1) {
    return res.data;
  }
  return Promise.reject(res.data.msg);
}

/* 添加会员 */
export async function add_member(params) {
  const res = await request.post(
    '/member/receipts_points_deduct/add_member',
    params
  );
  if (res.data.code === 1) {
    return res.data;
  }
  return Promise.reject(res.data.msg);
}
